using UnityEngine;
using System.Collections;

public class Tiro_Mao : MonoBehaviour
{
    public static int id = 39;

    void Start()
    {
        this.gameObject.AddComponent("MeshRenderer");
        this.gameObject.AddComponent("MeshFilter");

        this.gameObject.transform.localPosition = new Vector3(3.603684f, -3.102236f, -1);

        Mesh mesh = Quad.Create(1f, 1f);

        this.gameObject.GetComponent<MeshFilter>().mesh = mesh;
        this.gameObject.GetComponent<MeshRenderer>().material = AtlasManager.globalMaterial;

        this.gameObject.GetComponent<MeshFilter>().mesh.uv = new Vector2[]
		{
			new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMax),
			new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMax),
			new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMin),
			new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMin)
		};
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            id = 40;
            this.gameObject.GetComponent<MeshFilter>().mesh.uv = new Vector2[]
		    {
			    new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMax),
			    new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMax),
			    new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMin),
			    new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMin)
		    };
        }

        if (Input.GetMouseButtonUp(0))
        {
            id = 39;
            this.gameObject.GetComponent<MeshFilter>().mesh.uv = new Vector2[]
		    {
			    new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMax),
			    new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMax),
			    new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMin),
			    new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMin)
		    };
        }
    }
}